home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions Axon component
-
- #include "NSDLL.h"
-
- /***********************************/
- /* Forward activation of component */
-
- __declspec(dllexport) void performFuzzyAxon(
- DLLData *instance, // Pointer to instance data (may be NULL)
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *param, // Pointer to the layer of parameters for the MFs
- int paramIndex, // Index into the param array
- int PEIndex, // Index into the processing elements of the Axon
- // (the data array)
- NSFloat *returnVal // Value to return after applying the MF
- )
- {
- int baseIndex = paramIndex * 3;
- NSFloat a = *(param + baseIndex);
- NSFloat b = *(param + baseIndex + 1);
- NSFloat c = *(param + baseIndex + 2);
- if (a == 0.0f)
- *returnVal = 0.0f;
- else {
- NSFloat tmp1 = (*(data + PEIndex) - c) / a;
- NSFloat tmp2 = tmp1 == 0.0f ? 0.0f : (NSFloat)pow(tmp1*tmp1, b);
- *returnVal = (1 / (1 + tmp2));
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
-
- __declspec(dllexport) DLLData *allocFuzzyAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- int *paramCount // Number of parameters per MF
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- *paramCount = 3;
- return instance;
- }
-
- __declspec(dllexport) void freeFuzzyAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-